package com.zzyl.nursing.mapper;

import java.util.List;
import com.zzyl.nursing.domain.FamilyMember;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zzyl.nursing.domain.NursingProject;
import com.zzyl.nursing.domain.Reservation;
import com.zzyl.nursing.dto.ProjectAddDto;
import com.zzyl.nursing.dto.ProjectPageDto;
import com.zzyl.nursing.dto.ReservationPageDto;
import com.zzyl.nursing.vo.ReservationCountVo;
import com.zzyl.nursing.vo.ReservationPageVo;
import org.apache.ibatis.annotations.*;

/**
 * 老人家属Mapper接口
 * 
 * @author ruoyi
 * @date 2025-08-26
 */
@Mapper
public interface FamilyMemberMapper extends BaseMapper<FamilyMember>
{
    /**
     * 查询老人家属
     * 
     * @param id 老人家属主键
     * @return 老人家属
     */
    public FamilyMember selectFamilyMemberById(Long id);

    /**
     * 查询老人家属列表
     * 
     * @param familyMember 老人家属
     * @return 老人家属集合
     */
    public List<FamilyMember> selectFamilyMemberList(FamilyMember familyMember);

    /**
     * 新增老人家属
     * 
     * @param familyMember 老人家属
     * @return 结果
     */
    public int insertFamilyMember(FamilyMember familyMember);

    /**
     * 修改老人家属
     * 
     * @param familyMember 老人家属
     * @return 结果
     */
    public int updateFamilyMember(FamilyMember familyMember);

    /**
     * 删除老人家属
     * 
     * @param id 老人家属主键
     * @return 结果
     */
    public int deleteFamilyMemberById(Long id);

    /**
     * 批量删除老人家属
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFamilyMemberByIds(Long[] ids);

    List<FamilyMember> selectFamilyList(FamilyMember familyMember);

    List<NursingProject> selectNursingProjectList(ProjectPageDto projectPageDto);

    NursingProject selectNursingProjectById(Long id);

    @Select("select count(*) from reservation where status = 2")
    int selectCancelledCount();

    List<ReservationCountVo> selectReservationCountByTime(Long time);

    List<ReservationPageVo> selectreservationList(ReservationPageDto reservationPageDto);

    @Insert("INSERT INTO reservation (mobile, name, time, type, visitor, create_by, create_time, update_by, update_time, remark, status) " +
            "VALUES (#{mobile}, #{name}, #{time}, #{type}, #{visitor}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark}, #{status})")
    void insertReservation(Reservation reservation);

    @Update("UPDATE reservation SET status = #{status}, update_by = #{updateBy}, update_time = #{updateTime} WHERE id = #{id}")
    void updateReservation(Reservation reservation);

    @Select("SELECT * FROM reservation WHERE id = #{id}")
    Reservation selectReservationById(Long id);

    @Update("update reservation set status = 2 where id =#{id}")
    void cancelReservation(Long id);
}
